package com.itheima04;

import java.util.function.Consumer;

public class ConsumerTest {
    public static void main(String[] args) {

        String[] strArray = {"张三,18", "李四,20", "王武,26"};
//        printInfo(strArray,s -> {
//            String s1 = s.split(",")[0];
//            System.out.print("姓名：" + s1);
//        }, s -> {
//            String s1 = s.split(",")[1];
//            System.out.println("，年龄：" + s1);
//        });

        printInfo(strArray, s -> System.out.print("姓名：" + s.split(",")[0]), s -> System.out.println("，年龄" + s.split(",")[1]));
    }

    private static void printInfo(String[] strArray, Consumer<String> c1, Consumer<String> c2) {
        for (String s : strArray) {
            c1.andThen(c2).accept(s);
        }
    }
}
